#include "FPSCounter.h"


FPSCounter::FPSCounter(int frameTestPeriod)
{
	m_frameCount = 0;
	m_maxFrameCount = frameTestPeriod;
	m_fpsSum = 0;
	m_lastFPS = 0.0f;
}
FPSCounter::~FPSCounter(void)
{
}
void FPSCounter::PushFrameTime(double fTime)
{
	m_fpsSum += fTime;
	m_frameCount++;

	if(m_frameCount >= m_maxFrameCount)
	{
		if(m_frameCount > 0)
		{
			m_lastFPS = (float)(1.0f / (float)(m_fpsSum / m_frameCount));
			m_frameCount = 0;
			m_fpsSum = 0;
		}
	}
}
float FPSCounter::GetFPS()
{
	return m_lastFPS;
}
